<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@include file="/WEB-INF/jsp/common/navigationRight.jsp" %>
<%@include file="/WEB-INF/jsp/common/head.jsp" %>
<%@include file="/WEB-INF/jsp/common/navigationLeft.jsp" %>


<div class="m2-ticketCon">
    <div class="m2-ticketHead">
        <h3><i class="m2-tickHead-red1"></i>我的红包</h3>
    </div>
    <div class="m2-recharge-tips" style="margin-bottom:10px;">
        <p class="m2-ticPsg-nor">红包使用</p>
        <ul style="padding-bottom:18px;">
            <li><i class="m2-recharge-tips01"></i><b>投资时根据单笔投资金额选择红包</b></li>
            <li><i class="m2-recharge-tips02"></i><b>一次投资可使用一个红包</b></li>
            <li><i class="m2-recharge-tips03"></i><b>红包过期后将不能使用</b></li>
        </ul>
    </div>

    <div class="m2-ticketHead">
        <h3><i class="m2-tickHead-red2"></i>红包列表</h3>
    </div>
    <div class="m2-ticSearch">
        <ul>
            <li class="m2-ticSea-tit">红包状态：</li>
            <li class="m2-ticSea-sel m2-ticSea-click" onclick="showTab(1)"><span>未使用</span></li>
            <li class="m2-ticSea-unsel m2-ticSea-click" onclick="showTab(2)"><span>已使用</span></li>
            <li class="m2-ticSea-unsel m2-ticSea-click" onclick="showTab(3)"><span>已过期</span></li>
        </ul>
    </div>

    <%--<div id="tab1" class="m2-ticSea-sel-content">--%>
    <%--<div class="m2-ticResult">--%>
    <%--<div class="m2-ticResult_container">--%>

    <%--<div class="m2_ticresult_reword m2_ticresult_unuse">--%>
    <%--<div class="packet_title">--%>
    <%--<span>注册奖励</span>--%>
    <%--<span class="packet_where"></span>--%>
    <%--</div>--%>
    <%--<div class="packet_introduce_left">--%>
    <%--<span class="number">8</span>--%>
    <%--<span class="unit">元</span>--%>
    <%--</div>--%>
    <%--<div class="packet_introduce_right">--%>
    <%--<div class="packet_introduce_right_con">--%>

    <%--<p>·&nbsp;投资额≥200元可使用</p>--%>
    <%--</div>--%>
    <%--<i></i>--%>
    <%--</div>--%>
    <%--<div class="packet_bottom">--%>
    <%--<span>起效期：2016-09-05</span>--%>
    <%--<span class="packet_endtime">有效期至：2016-09-12 09:29:52</span>--%>
    <%--</div>--%>
    <%--</div>--%>

    <%--<div class="m2-ticTotbottom-red">--%>
    <%--<span><i></i><span id="wsyljkyze">累计可用总额：38元</span></span>--%>
    <%--</div>--%>
    <%--</div>--%>
    <%--</div>--%>
    <%--<div id="tab2" class="m2-ticSea-sel-content" style="display:none;">--%>
    <%--<div class="m2-ticResult">--%>
    <%--<div class="m2-ticResult_container">--%>
    <%--</div>--%>
    <%--<div class="m2-ticTotbottom-red">--%>
    <%--<span><i></i><span id="ysyljkyze">累计可用总额：0元</span></span>--%>
    <%--</div>--%>
    <%--</div>--%>
    <%--</div>--%>
    <div id="tab1" class="">
        <div class="m2-ticResult">
            <div id="list1" class="m2-ticResult_container">
                <table id="tab-zyf" style="width: 100%;">
                    <tr>
                        <td style="border:1px solid #c0c0c0">红包金额</td>
                        <td style="border:1px solid #c0c0c0">领取日期</td>
                        <td style="border:1px solid #c0c0c0">过期时间</td>
                        <td style='border:1px solid #c0c0c0'>使用条件</td>
                    </tr>
                </table>
            </div>
            <div class="m2-ticTotbottom-add">
                <span id="total1"><i></i>累计可用红包总金额：<span id="val-zyf">0</span>元</span>
            </div>
        </div>
        <%--<%@include file="/WEB-INF/jsp/common/rollpage.jsp" %>--%>
        <div class="page-bar">
            <ul class="page-num-ul clearfix">
                <li>共<span class="zyf-totalCount"></span>条记录&nbsp;&nbsp; <span class="zyf-currentPageNo"></span>/<span class="zyf-totalPageCount"></span> 页</li>
                <a class="zyf-first">首页</a>
                <a class="zyf-prev">上一页</a>
                <a class="zyf-second">下一页</a>
                <a class="zyf-last">最后一页</a>
                &nbsp;&nbsp;
            </ul>
            <span class="page-go-form"><label>跳转至</label>
             <input type="text" name="inputPage" id="inputPage" class="page-key" />页
             <button type="button" class="page-btn" onClick='jump_to(document.getElementById("inputPage").value)'>GO</button>
            </span>
        </div>
        <div style="display: none">
            <span id="sta"></span>
            <span id="all"></span>
            <span id="name"></span>
        </div>
    </div>
</div>



    <%--<div id="tab3" class="m2-ticSea-sel-content" style="display:none;">--%>
        <%--<div class="m2-ticResult">--%>
            <%--<div class="m2-ticResult_container">--%>
            <%--</div>--%>
            <%--<div class="m2-ticTotbottom-red">--%>
                <%--<span><i></i><span id="ygqljkstze">累计可用总额：0元</span></span>--%>
            <%--</div>--%>
        <%--</div>--%>
    <%--</div>--%>
    <%--<div class="m2-ticMoreadd">--%>
        <%--<span>加载更多</span>--%>
    <%--</div>--%>
</div>
<script type="text/javascript">

    //筛选栏点击
    $('.m2-ticSearch ul li').click(function () {
        if ($(this).hasClass('m2-ticSea-unsel')) {
            $(".m2-ticSea-click").addClass('m2-ticSea-unsel').removeClass('m2-ticSea-sel');
            $(this).addClass('m2-ticSea-sel').removeClass('m2-ticSea-unsel');
            $(".m2-ticSea-sel-content").hide();
            $("#tab" + $(this).attr("data")).show();
        }
    });

    var index = [0, 1, 1, 1];
    var total = [0, 0, 0, 0];
    var async = false;
    getMore(1,1);
    // getMore(2);
    // getMore(3);

    function showTab(index) {
        /*$('#tab1').hide();
        $('#tab2').hide();
        $('#tab3').hide();*/
        /*$('#tab' + index).show();*/
        $('#tab1').show();
        getMore(index,0);
    }

    //日期加上天数得到新日期
    function addDate(date, days) {
        if(days == undefined || days == '') {
            days = 1;
        }
        var date = new Date(date);
        date.setDate(date.getDate() + days);
        var month = date.getMonth() + 1;
        var day = date.getDate();
        var mm = "'" + month + "'";
        var dd = "'" + day + "'";

        //单位数前面加0
        if(mm.length == 3) {
            month = "0" + month;
        }
        if(dd.length == 3) {
            day = "0" + day;
        }

        var time = date.getFullYear() + "-" + month + "-" + day
        return time;
    }

    function getMore(cate,currentPageNo) {
        $.ajax({
            url: '/hongbao/hongbaoList',
            type: 'POST',
            data: {"status": cate,"currentPageNo":currentPageNo},
            dataType:'json',
            success: function (data) {
                var str="";
                var num = data.hongbaoCount;
                /*$(data).each(function () {
                    var tim = addDate(this.createTime,this.time);
                    str="<tr class='tab-sum'>";
                    str="<td>"+this.type+"</td>";
                    str="<td>"+this.createTime+"</td>";
                    str="<td>"+tim+"</td>";
                    str="<td>"+this.sustainDate+"</td>";
                    str="<td>"+this.scope+"</td>";
                    str="</tr>";
                });*/
                /*for (var i in obj['list']){
                    var tim = addDate(obj['list'][i]['createTime'],obj['list'][i]['time']);
                    str="<tr class='tab-sum'>";
                    str="<td>"+obj['list'][i]['type']+"</td>";
                    str="<td>"+obj['list'][i]['createTime']+"</td>";
                    str="<td>"+tim+"</td>";
                    str="<td>"+obj['list'][i]['sustainDate']+"</td>";
                    str="<td>"+obj['list'][i]['scope']+"</td>";
                    str="</tr>";
                }*/
                for (var p of data.aqbaqbPacket){
                    // num = num + 1;
                    var tim = addDate(p.createTime,p.hongTimeDuration);
                    str +="<tr class='tab-sum'>";
                    str +="<td style='border:1px solid #c0c0c0'>"+p.hongTypeValue+"</td>";
                    str +="<td style='border:1px solid #c0c0c0'>"+addDate(p.createTime,0)+"</td>";
                    str +="<td style='border:1px solid #c0c0c0'>"+tim+"</td>";
                    str +="<td style='border:1px solid #c0c0c0'>"+p.useCondition+"</td>";
                    str +="</tr>";
                }
                /*str +="<div class='page-bar'>";
                str +="<ul class='page-num-ul clearfix'>";
                str +="<li>共"+data.phs.totalCount+"条记录&nbsp;&nbsp;"+data.phs.currentPageNo+"/"+data.phs.totalPageCount+" 页</li>";
                str +="<a>首页</a>";
                str +="<a>上一页</a>";
                str +="<a>下一页</a>";
                str +="<a>最后一页</a>";
                str +="&nbsp;&nbsp";
                str +="</ul>";
                str +="<span class='page-go-form'><label>跳转至</label>";
                str +="<input type='text' name='inputPage' id='inputPage' class='page-key' />页";
                str +="<button type='button' class='page-btn'>GO</button>";
                str +="</span>";
                str +="</div>";*/
                $(".tab-sum").remove();
                $("#tab-zyf").append(str);
                $("#val-zyf").html(num);
                $(".zyf-totalCount").html(data.phs.totalCount);
                $(".zyf-currentPageNo").html(data.phs.currentPageNo);
                $(".zyf-totalPageCount").html(data.phs.totalPageCount);

                $("#sta").html(data.status);
                $("#name").html(data.phs.currentPageNo);
                $("#all").html(data.phs.totalPageCount);
                //$("#sta").attr("value",data.status).attr("name",data.phs.currentPageNo).attr("all",data.phs.totalPageCount);
                //$(".zyf-hidden").html("<input type='hidden' id='zyf-pageNo' value='"+data.phs.currentPageNo+"'/><input type='hidden' id='zyf-pageAll' value='"+data.phs.totalPageCount+"'/>");

                /*var obj = eval('(' + data + ')');
                var str = "";
                var dataStr = "";
                var qx = "";
                for (var i in obj['list']) {
                    total[cate]++;
                    if (cate == 1) {
                        str = "<div class='m2_ticresult_reword m2_ticresult_unuse'>";
                        $('#total' + cate).html('<i></i>累计可用加息卷：' + total[cate] + '个');
                    } else if (cate == 2) {
                        str = " <div class='m2_ticresult_reword m2_ticresult_hasused'>";
                        $('#total' + cate).html('<i></i>累计已使用加息卷：' + total[cate] + '个');
                    } else if (cate == 3) {
                        str = " <div class='m2_ticresult_reword m2_ticresult_endtime'>";
                        $('#total' + cate).html('<i></i>累计已过期加息卷：' + total[cate] + '个');
                    }

                    if (obj['list'][i]['allow_project_period'] == 1) {
                        qx = "·&nbsp;限投" + obj['list'][i]['allow_project_period'] + "个月项目";
                    } else if (obj['list'][i]['allow_project_period'] == 0) {

                    } else {
                        qx = "·&nbsp;限投" + obj['list'][i]['allow_project_period'] + "个月及以下项目";
                    }

                    dataStr += str + "<div class='packet_title'><span>" + obj['list'][i]['info'] + "</span>"
                        + "<span class='packet_where'>" + obj['list'][i]['allow_client_type'] + "</span></div><div class='packet_introduce_left'>"
                        + "<span class='number'>" + obj['list'][i]['percentage'] + "</span><span class='unit'>%</span></div>"
                        + "<div class='packet_introduce_right'><div class='packet_introduce_right_con'><p>" + qx + "</p><p>"
                        + "·&nbsp;投资额≥" + obj['list'][i]['use_condition'] + "元可使用</p></div><i></i></div><div class='packet_bottom'><span>起效期：" + obj['list'][i]['date1'] + "</span><span class='packet_endtime'>有效期至：" + obj['list'][i]['date2'] + "</span></div></div>";*/

            },
            error:function () {
                alert("sss");
            }

            /*$('#list' + cate).append(dataStr);
            if (obj['totalpage'] <= index[cate]) {
                $('#loadmore' + cate).hide();
            }
            index[cate]++;
        }*/
        });

    }

    $(".zyf-first").click(function () {
        var cate = $("#sta").html();
        getMore(cate,1);
    });
    $(".zyf-prev").click(function () {
        var cate = $("#sta").html();
        var currentPageNo = $("#name").html()*1;
        var s= currentPageNo-1;
        if(s <= 0){
            s = 1;
        }
        getMore(cate,s);
    });
    $(".zyf-second").click(function () {
        var cate = $("#sta").html();
        var currentPageNo = $("#name").html()*1;
        var pageAll = $("#all").html()*1;
        if(currentPageNo+1 > pageAll){
            getMore(cate,pageAll);
        }else{
            getMore(cate,currentPageNo+1);
        }
    });
    $(".zyf-last").click(function () {
        var cate = $("#sta").html();
        var currentPageNo = $("#all").html()*1;
        getMore(cate,currentPageNo);
    });
    //跳转
    function jump_to(ddddd) {
        var cate = $("#sta").html();
        getMore(cate,ddddd);
    }

    //发送页数的数组
    // var selectpage = [2, 2, 2];
    //
    // $(".m2-ticMoreadd").click(function () {
    //     var type = $(".m2-ticSearch .m2-ticSea-sel").attr("data");
    //     var page = selectpage[Number(type) - 1];
    //     var dataStr;
    //     $.ajax({
    //         url: '/hongbao/hongbaoList',
    //         type: 'POST',
    //         data: {
    //             index: page,
    //             cate: type,
    //             type: 1,
    //             status: cate,
    //             currentPageNo:currentPageNo
    //         },
    //         success: function (data) {
    //             var obj = eval('(' + data + ')');
    //             var str = "";
    //             var dataStr = "";
    //
    //             for (var i in obj['list']) {
    //                 var xtwz = "";
    //                 if (type == 1) {
    //                     if (obj['list'][i]['type'] == 1) {
    //                         str = "<div class='m2_ticresult_reword m2_ticresult_unuse'>";
    //                     } else if (obj['list'][i]['type'] == 3) {
    //                         str = "<div class='m2_ticresult_reword m2_ticresult_unactive'>";
    //                     }
    //                 } else if (type == 2) {
    //                     str = " <div class='m2_ticresult_reword m2_ticresult_hasused'>";
    //                 } else if (type == 3) {
    //                     str = " <div class='m2_ticresult_reword m2_ticresult_endtime'>";
    //                 }
    //                 console.log(obj['list'][i]['allow_project_period']);
    //                 if (obj['list'][i]['allow_project_period'] == 0) {
    //
    //                 } else {
    //                     xtwz = "·&nbsp;限投" + obj['list'][i]['allow_project_period'] + "个月及以上项目";
    //                 }
    //
    //                 dataStr += str + "<div class='packet_title'><span>" + obj['list'][i]['info'] + "</span>"
    //                     + "<span class='packet_where'>" + obj['list'][i]['allow_client_type'] + "</span></div><div class='packet_introduce_left'>"
    //                     + "<span class='number'>" + obj['list'][i]['money'] + "</span><span class='unit'>元</span></div>"
    //                     + "<div class='packet_introduce_right'><div class='packet_introduce_right_con'><p>" + xtwz + "</p><p>"
    //                     + "·&nbsp;投资额≥" + obj['list'][i]['use_condition'] + "元可使用</p></div><i></i></div><div class='packet_bottom'><span>起效期：" + obj['list'][i]['date1'] + "</span><span class='packet_endtime'>有效期至：" + obj['list'][i]['date2'] + "</span></div></div>";
    //             }
    //             if (type == 1) {
    //                 wsyljze = Number(wsyljze) + Number(obj['ljkyze']);
    //                 $("#wsyljkyze").html("累计可用总额：" + wsyljze + "元");
    //             } else if (type == 2) {
    //                 ysyljze = Number(ysyljze) + Number(obj['ljkyze']);
    //                 $("#ysyljkyze").html("累计可用总额：" + ysyljze + "元");
    //             } else if (type == 3) {
    //                 ygqljze = Number(ygqljze) + Number(obj['ljkyze']);
    //                 $("#ygqljkstze").html("累计可用总额：" + ygqljze + "元");
    //             }
    //
    //             $("#tab" + type).find(".m2-ticResult_container").append(dataStr);
    //             selectpage[Number(type) - 1]++;
    //         }
    //     });
    // });


</script>
</body>
</html>